/*
 * @Author: tanjunyi@doctorwork.com
 * @Date: 2020-06-15 22:58:11
 * @LastEditors: tanjunyi@doctorwork.com
 * @LastEditTime: 2020-06-26 21:53:58
 * @Description:
 */
import { initMixin } from './init';
import { renderMixin } from './render';
import { lifeCycleMixin } from './lifecyle';
import { initGlobalApi } from './global-api/index';

function Vue(options) {
	this._init(options)
}

initMixin(Vue);
renderMixin(Vue);
lifeCycleMixin(Vue);
// 扩展全局方法
initGlobalApi(Vue);

// -------------------------- diff -----------------
import { compildToFunction } from './compiler/index';


import { createElm, patch } from './vdom/patch'

let vm1 = new Vue({ data: { name: 'cc' } });
let vm2 = new Vue({ data: { name: 'dd' } });

let render1 = compildToFunction(`<div >
	<li key="A" id="B">A</li>
	<li key="B">B</li>
	<li key="C">C</li>
	<li key="D">D</li>
</div>`);

let oldVnode = render1.call(vm1);

let realElement = createElm(oldVnode);
document.body.appendChild(realElement)


let render2 = compildToFunction(`<div >
	<li key="C">C</li>
	<li key="D">D</li>
	<li key="M" >M</li>
	<li key="E">E</li>
</div>`);
let newVnode = render2.call(vm2);

console.log("oldVnode:", oldVnode)
console.log("newVnode:", newVnode)


setTimeout(() => {
	patch(oldVnode, newVnode); //虚拟节点之间的比对
}, 2000)

export default Vue;